package com.hc.javabasestudyproject.feature.stream;

import com.hc.javabasestudyproject.feature.entity.Author;
import com.hc.javabasestudyproject.feature.entity.DataUtils;

import java.util.Arrays;
import java.util.List;

/**
 * @Author: huangcheng
 * @CreateTime: 2023-11-22  16:45
 * @Description:
 * @Version: 1.0
 */
public class matchStream {
    public static void main(String[] args) {
        List<Author> dataList = DataUtils.getAuthors();
        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);

        boolean allMatch = list.stream().allMatch(e -> e > 10); //false
        boolean noneMatch = list.stream().noneMatch(e -> e > 10); //true
        boolean anyMatch = list.stream().anyMatch(e -> e > 4);  //true

        Integer findFirst = list.stream().findFirst().get(); //1
        Integer findAny = list.stream().findAny().get(); //1

        long count = list.stream().count(); //5
        Integer max = list.stream().max(Integer::compareTo).get(); //5
        Integer min = list.stream().min(Integer::compareTo).get(); //1
    }
}
